using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
	public class areatrigger_teleport : MangosBase
	{
		public System.UInt32? id;
		public System.String name;
		public System.Byte? required_level;
		public System.UInt32? required_item;
		public System.UInt32? required_item2;
		public System.UInt32? heroic_key;
		public System.UInt32? heroic_key2;
		public System.UInt32? required_quest_done;
		public System.UInt32? required_quest_done_heroic;
		public System.String required_failed_text;
		public System.UInt16? target_map;
		public System.Single? target_position_x;
		public System.Single? target_position_y;
		public System.Single? target_position_z;
		public System.Single? target_orientation;




		public override string GetInsertCommand()
		{
			return string.Format("INSERT IGNORE INTO `areatrigger_teleport` (`id`, `name`, `required_level`, `required_item`, `required_item2`, `heroic_key`, `heroic_key2`, `required_quest_done`, `required_quest_done_heroic`, `required_failed_text`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}');", id.GetValueOrDefault(), name.MySQLDBString(), required_level.GetValueOrDefault(), required_item.GetValueOrDefault(), required_item2.GetValueOrDefault(), heroic_key.GetValueOrDefault(), heroic_key2.GetValueOrDefault(), required_quest_done.GetValueOrDefault(), required_quest_done_heroic.GetValueOrDefault(), required_failed_text.MySQLDBString(), target_map.GetValueOrDefault(), target_position_x.GetValueOrDefault(), target_position_y.GetValueOrDefault(), target_position_z.GetValueOrDefault(), target_orientation.GetValueOrDefault());
		}


		public override string GetUpdateCommand()
		{
            StringBuilder sb = new StringBuilder();
						sb.Append("UPDATE `areatrigger_teleport` SET ");
			if(name != null)
			{
				sb.AppendLine("`name`='" + name.MySQLDBString() + "'");
			}
			if(required_level != null)
			{
				sb.AppendLine("`required_level`='" + required_level.Value.ToString() + "'");
			}
			if(required_item != null)
			{
				sb.AppendLine("`required_item`='" + required_item.Value.ToString() + "'");
			}
			if(required_item2 != null)
			{
				sb.AppendLine("`required_item2`='" + required_item2.Value.ToString() + "'");
			}
			if(heroic_key != null)
			{
				sb.AppendLine("`heroic_key`='" + heroic_key.Value.ToString() + "'");
			}
			if(heroic_key2 != null)
			{
				sb.AppendLine("`heroic_key2`='" + heroic_key2.Value.ToString() + "'");
			}
			if(required_quest_done != null)
			{
				sb.AppendLine("`required_quest_done`='" + required_quest_done.Value.ToString() + "'");
			}
			if(required_quest_done_heroic != null)
			{
				sb.AppendLine("`required_quest_done_heroic`='" + required_quest_done_heroic.Value.ToString() + "'");
			}
			if(required_failed_text != null)
			{
				sb.AppendLine("`required_failed_text`='" + required_failed_text.MySQLDBString() + "'");
			}
			if(target_map != null)
			{
				sb.AppendLine("`target_map`='" + target_map.Value.ToString() + "'");
			}
			if(target_position_x != null)
			{
				sb.AppendLine("`target_position_x`='" + target_position_x.Value.ToString() + "'");
			}
			if(target_position_y != null)
			{
				sb.AppendLine("`target_position_y`='" + target_position_y.Value.ToString() + "'");
			}
			if(target_position_z != null)
			{
				sb.AppendLine("`target_position_z`='" + target_position_z.Value.ToString() + "'");
			}
			if(target_orientation != null)
			{
				sb.AppendLine("`target_orientation`='" + target_orientation.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `id`='" + id.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}


	}
}
